/*
* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.hslu.dmg.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author zaoln
 */
@Entity
@Table(name = "Fertigung")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fertigung.findAll", query = "SELECT f FROM Fertigung f"),
    @NamedQuery(name = "Fertigung.findById", query = "SELECT f FROM Fertigung f WHERE f.id = :id")})
public class Fertigung implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id")
    private Long id;
    @OneToMany(mappedBy = "fertigungid")
    private List<Teil> teilList;
    @JoinColumn(name = "Machine_id", referencedColumnName = "Machine_id")
    @ManyToOne
    private Maschine machineid;

    public Fertigung() {
    }

    public Fertigung(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @XmlTransient
    public List<Teil> getTeilList() {
        return teilList;
    }

    public void setTeilList(List<Teil> teilList) {
        this.teilList = teilList;
    }

    public Maschine getMachineid() {
        return machineid;
    }

    public void setMachineid(Maschine machineid) {
        this.machineid = machineid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fertigung)) {
            return false;
        }
        Fertigung other = (Fertigung) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fp.Fertigung[ id=" + id + " ]";
    }
    
}
